﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace The_LarX
{
    public class Renderer_Basic : Renderer
    {
        /*private List<Actor> Actors;

        public Renderer_Basic()
        {
            Actors = new List<Actor>();
        }

        public override void RemapModel(ref Model Model)
        {
        }

        public override void SubmitActor(Actor actor)
        {
            Actors.Add(actor);
        }

        /// <summary>
        /// Render all the Stored Actors, with the Stored Lights. This method
        /// WILL clear the BackBuffer
        /// </summary>
        public override void RenderActors()
        {
            if (Camera != null)
            {
                for (int i = 0; i < Actors.Count; i++)
                {
                    DrawActor(Actors[i]);
                }

            }
            Actors.Clear();
        }

        private void DrawActor(Actor actor)
        {
            Engine.GraphicsDevice.BlendState = BlendState.Opaque;
            Engine.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            Engine.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
            //Engine.GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
            // Copy any parent transforms.
            Matrix[] AbsolutTransforms = new Matrix[actor.Model.Bones.Count];
            actor.Model.CopyAbsoluteBoneTransformsTo(AbsolutTransforms);

            foreach (ModelMesh Mesh in actor.Model.Meshes)
            {
                foreach (BasicEffect Effect in Mesh.Effects)
                {
                    Matrix localWorld = AbsolutTransforms[Mesh.ParentBone.Index] * actor.World;
                    Effect.LightingEnabled = true;
                    Effect.PreferPerPixelLighting = true;
                    Effect.EnableDefaultLighting();
                    Effect.World = localWorld;
                    Effect.View = Camera.View;
                    Effect.Projection = Camera.Projection;
                    //Effect.TextureEnabled = actor.Material.Textured;                    
                    //Effect.Texture = actor.Material.Texture;
                    //Effect.DiffuseColor = actor.Material.DiffuseColor;

                    //if (actor.Material.Textured)
                        //Effect.DiffuseColor = Color.White.ToVector3();
                }
                Mesh.Draw();
            }
        }*/
    }
}
